/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TransferProgressDialog.java
 *
 * Created on May 3, 2011, 3:00:13 AM
 */
package fss.client.ui;

/**
 *
 * @author hieu
 */
public class TransferProgressDialog extends javax.swing.JDialog
{
  /** Creates new form TransferProgressDialog */
  public TransferProgressDialog()
  {
    initComponents();
    setVisible(false);
  }

  public void updateTransferProgress(boolean aIsDownload, int progress)
  {
    if (aIsDownload)
    {
      transferTypeLabel.setText("Download Progress");
    }
    else
    {
      transferTypeLabel.setText("Upload Progress");
    }

    percentageLabel.setText("" + progress + "%");

    if (!isVisible())
    {
      setLocationRelativeTo(null);
      setVisible(true);
    }
  }

  public void updateIncompleteTransferProgress()
  {
    transferTypeLabel.setText("Transfer Incomplete");
    percentageLabel.setText("Server is disconnected");
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    transferTypeLabel = new javax.swing.JLabel();
    percentageLabel = new javax.swing.JLabel();
    closeButton = new javax.swing.JButton();

    setTitle("Transfer Status");

    transferTypeLabel.setFont(new java.awt.Font("Ubuntu", 1, 18));
    transferTypeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    transferTypeLabel.setText("Transfer Type: ");

    percentageLabel.setFont(new java.awt.Font("Dialog", 1, 48));
    percentageLabel.setForeground(new java.awt.Color(0, 255, 0));
    percentageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    percentageLabel.setText("0%");

    closeButton.setText("Close");
    closeButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        closeButtonActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(percentageLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
          .addComponent(transferTypeLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
          .addComponent(closeButton, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE))
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(transferTypeLabel)
        .addGap(18, 18, 18)
        .addComponent(percentageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(closeButton)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_closeButtonActionPerformed
    {//GEN-HEADEREND:event_closeButtonActionPerformed
      setVisible(false);
    }//GEN-LAST:event_closeButtonActionPerformed
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton closeButton;
  private javax.swing.JLabel percentageLabel;
  private javax.swing.JLabel transferTypeLabel;
  // End of variables declaration//GEN-END:variables
}
